import java.util.Random;
<<<<<<< HEAD
import java.util.*;
import java.io.*;
=======

>>>>>>> f49695518890709d70783ac5be2244245270b9fe
public class demo
{
    public static void Sort(int [] a) {
        int len = a.length;//单独把数组长度拿出来，提高效率
        while (len != 0) {
            len = len / 2;
            for (int i = 0; i < len; i++) {//分组
                for (int j = i + len; j < a.length; j += len) {//元素从第二个开始
                    int k = j - len;//k为有序序列最后一位的位数
                    int temp = a[j];//要插入的元素
                    while (k >= 0 && temp < a[k]) {//从后往前遍历
                        a[k + len] = a[k];
                        k -= len;//向后移动len位
                    }
                    a[k + len] = temp;
                }
            }
        }
    }
<<<<<<< HEAD
    public static int max(int[] a) {
        Sort(a);
        int last = a.length-1;
        return a[last];
    }
=======
>>>>>>> f49695518890709d70783ac5be2244245270b9fe
    public static void main (String []args) {
        Random rand = new Random();
        int N = 10;
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = rand.nextInt(100);
        }
<<<<<<< HEAD
        for (int i =0; i<N;i++) {
            System.out.print(a[i]+" ");
        }
        System.out.print("\n");
        Sort (a);
        for (int i = 0; i < N; i++) {
            System.out.print( a[i]+" ");
        }
        int b = max(a);
        System.out.println("最大值是"+b);
    }
=======
        Sort (a);
        for (int i = 0; i < N; i++) {
            System.out.println(i + ":" + a[i]);
        }
    }

>>>>>>> f49695518890709d70783ac5be2244245270b9fe
}
